package com.tms.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtil {
    private SimpleDateFormat sdf = new SimpleDateFormat();// 格式化时间;

    public DateUtil() {
    }

    public Date getCurrentDate() throws ParseException {
        sdf.applyPattern("yyyy-MM-dd HH:mm");
        Date date = new Date();
        String temp = sdf.format(date);
        Date submitTime = sdf.parse(temp);// 获取当前时间
        return submitTime;
    }

    public String getBillNo() {
        sdf.applyPattern("yyyyMMddHHmm");
        Date date = new Date();
        String temp = sdf.format(date);
        String billNo = "BO" + temp;
        return billNo;
    }

    public Date getDate(String stringDate) {
        sdf.applyPattern("yyyy-MM-dd HH:mm");
        Date date = null;
        try {
            date = sdf.parse(stringDate);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return date;
    }
}
